<?php if(isset($errorMessage) && $errorMessage != ''): ?>
<input id="errorMessageHidden" type="hidden" value="<?php echo $errorMessage; ?>"/>
<?php endif; ?>
<?php foreach ($comments as $key => $comment): ?>
<?php $postClass ='user';
if($comment['Comment']['user_type'] == Comment::OWNER_TYPE){
	$postClass = 'owner';
}
?>
<div class="posted <?php echo $postClass;?>">
	<div class="postOwnerImage">
		<?php if(isset($comment['Profile']['icon_image']) && is_file(Configure::read('User.upload_dir_prefix').$comment['Profile']['icon_image'])): 
		echo $this->Html->image(Configure::read('User.upload_path_prefix').$comment['Profile']['icon_image'], array('alt' => 'user name', 'width' => '50', 'height' => '50'));
		else:
			echo $this->Html->image(Configure::read('User.default_icon_image'), array('alt' => 'user name', 'width' => '50', 'height' => '50'));
		endif; ?>
	</div>
	<div class="postedContent">
		<div class="parrentPosted">
			<div class="content">
				<h4 class="usernames">
					<?php if(is_array($comment['Profile']) && count($comment['Profile']) > 0 ):
						echo $this->Html->link($this->User->getUsername($comment), array('controller' => 'profile', 'action' => 'view', $comment['Profile']['user_id']));
					endif; ?>
					<?php if($comment['Comment']['user_type'] == Comment::OWNER_TYPE): ?>
					<span class="roleOwner">【講師】</span>
					<?php endif; ?>
				</h4>
				<div class="description">
					<?php echo $comment['Comment']['content']; ?>
				</div>
			</div>
			<ul class="postedNav">
				<?php if ($userLogon && $userId == $comment['Comment']['user_id']): ?>
				<?php if($showPostForm == true): ?>
					<li><a class="deleteComment" name="<?php echo $comment['Comment']['id']; ?>" href="javascript:void(0);">この投稿を削除する</a></li>
				<?php else:?>
					<li>
					<?php
					echo $this->Form->create('Comment', array('url' => array('controller' => 'Comments','action' => 'index', $courseId), 'type' => 'post', 'id' => 'formSubmit'.$comment['Comment']['id']));
					?>
					<input type="hidden" name="data[commentId]" value="<?php echo $comment['Comment']['id'];?>"/>
					<a class="deleteCommentLoad" name="<?php echo $comment['Comment']['id']; ?>" href="javascript:void(0);">この投稿を削除する</a>
					<?php
					echo $this->Form->end();
					endif;?>
					</li>
				<?php endif; ?>
				<li class="comment">
					<a class="totalReply" id="totalReply<?php echo $comment['Comment']['id']; ?>" href="javascript:void(0);">コメント数(<?php echo $comment['Comment']['total_reply'] ; ?>)</a>
					<input type="hidden" id="commentHidden<?php echo $comment['Comment']['id']; ?>" value="<?php echo $comment['Comment']['id']; ?>" class="commentHidden"/>
				</li>
			</ul>
		</div>
		<div id="warpReplyPostedContent<?php echo $comment['Comment']['id'];?>" class="replyPostedContent">
			<?php echo $this->element('comment/reply_item', array(
				'comment' => $comment['Reply'],
				'commentId' => $comment['Comment']['id'],
				'showPostForm' => $showPostForm,
				'userId' => $userId,
				'showAll' => $showAll
			)); ?>
		</div>
	</div>
</div><!-- /.posted -->
<?php endforeach;?>